<script>
    /**
     * 生成任意长度字符串
     * @param {Number} range 指定长度、范围，缺省16位
     * @return {String}
     */
    function casualStr(range) {
        const RS = [];
        try {
            if (!range) {
                range = 16;
            }

            const chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"/* .split('') */;
            const len = chars.length;

            for (let i = 0; i < range; i++) {
                RS.push(
                    chars.charAt(Math.floor(Math.random() * len))
                );
            }
            return RS.join('');
        } catch (e) {
            console.log(`casualStr error:${e.message}`);
            return RS.join('');
        }
    }


   console.log( casualStr(16));
</script>